	var gold_top = "";
	var gold_bottom = "";
	var intervalId = "";
	var arraySize = "";
	var changeSec = "6000";
	var leftTime;
	$().ready(function(){
		leftTime = $("#tlsEndTime").text()-$("#systemTime").text();
		setInterval(countLeft,1000);
		$("#main-gold-1").hide();
		$("div.sel-box > a").eq(0).attr("class","sel-num1");
		//random show maingold
		arraySize = $("div.sel-box > a").length;
		var maingoldNum = $.random($("div.sel-box > a").length);
		$("#main-gold-" + (maingoldNum + 1)).show();
		$("div.sel-box > a").eq(maingoldNum).attr("class",$("div.sel-box > a").eq(maingoldNum).attr("class") + "f");
		init5Tabs();
		//每六秒自動跳tab,当滑鼠移到上面时则不执行
		$("a[class*='sel-num']").each(function(){
			$(this).mouseenter(function(){
				gold_top = $(this);
				clearInterval(intervalId);
			});
			$(this).mouseleave(function(){
				gold_top = "";
				intervalId = setInterval(showRotatingTab,changeSec);
			});
		});
		$("div[id*='main-gold-']").each(function(){
			$(this).mouseenter(function(){
				gold_bottom = $(this);
				clearInterval(intervalId);
			});
			$(this).mouseleave(function(){
				gold_bottom = "";
				intervalId = setInterval(showRotatingTab,changeSec);
			});
		});
		//random show top
		var midNum = $.random(4);
		$("div.mid-box.box-up > div.filterbar > a").eq(midNum).addClass("nowfcous");
		$("#up-sale-bar-" + (midNum + 1)).show();	
		//random show mid
		var topNum = $.random(4);
		$("div.mid-box.box-mid > div.filterbar > a").eq(topNum).addClass("nowfcous");
		$("#mid-sale-bar-" + (topNum + 1)).show();		
		//ramdom show btm
		var btmNum = $.random(4);
		$("div.mid-box.box-down > div.filterbar > a").eq(btmNum).addClass("nowfcous");
		$("#down-sale-bar-" + (btmNum + 1)).show();
		//default tab3
		$("div#tab3_idx > div").eq(0).hide();		
		var tab3Num = $.random(3);
		$("div#tab3_idx > ul.tab-right > li").eq(tab3Num).attr("class",$("div#tab3_idx > ul.tab-right > li").eq(tab3Num).attr("class")+"f");
		$("div#tab3_idx > div").eq(tab3Num).show();
		//goldfour
		var goldfourNum = $.random(3);
		$("div.gold-four > div.gold-four-show").eq(0).hide();		
		$("div.gold-four > ul.tab-right > li").eq(goldfourNum).attr("class",$("div.gold-four > ul.tab-right > li").eq(goldfourNum).attr("class")+"f");
		$("div.gold-four > div.gold-four-show").eq(goldfourNum).show();
		//活动快讯、强力放送
		$("div.rightbox.infoarea > div").show();
		$("div.rightbox.broadcast > div").show();
	});
	function mainGoldRotating(){
		//共有幾個tab
		var myImg = new Array(arraySize);
		for( i = 1; i = arraySize; i++){
			myImg[i-1] = i;
		}
		//要取幾張來播放
		var playImg = new Array(arraySize);
		//目前播放到第幾張
		var nowIndex;
		$("div.sel-box > a").each(function(index,item){
			if ( $(this).attr("class").indexOf("f") != -1 ){
				nowIndex = index;
			}
		});
		//從allImg中取出N張放到myImg裡面
		for(var i = 0;i < playImg.length;i++){
			playImg[i] = myImg[nowIndex];
			nowIndex++;
			if (nowIndex > (arraySize-1)) nowIndex = 0;
		}
	}
	function showRotatingTab(){
		//共有幾個tab
		var myImg = new Array(arraySize);
		for( i = 0 ; i < arraySize ; i++ ){
			myImg[i] = i;
		}
		//要取幾張來播放
		var playImg = new Array(arraySize);
		//目前播放到第幾張
		var nowIndex = 0;
		var tempNowIndex = 0;
		$("div.sel-box > a").each(function(index,item){
			var thisClass = $(this).attr("class");
			if ( thisClass.indexOf("f") > -1 ){
				nowIndex = index;
				$(this).attr("class","sel-num" + (index+1));
			}
		});
		tempNowIndex = nowIndex;
		$("div[id*='main-gold-']").each(function(){
			$(this).hide();
		});
		tempNowIndex++;
		if (tempNowIndex > (arraySize-1)) tempNowIndex = 0;
		//eq從0開始算
		$("div.sel-box > a").eq(myImg[tempNowIndex]).attr("class",$("div.sel-box > a").eq(myImg[tempNowIndex]).attr("class") + "f");
		//traceVirtualPage(_admain[parseInt(myImg[tempNowIndex],10)]);
		$("#main-gold-" + (parseInt(myImg[tempNowIndex],10)+1)).show();
	}	
	function init5Tabs(){
		if ( gold_bottom == "" && gold_top == "" )
			intervalId = setInterval(showRotatingTab,changeSec);
	}
	function countLeft(){
		if(leftTime>=0){
			var showText;
			var tmp = leftTime%3600;
			var h = (leftTime-tmp)/3600;
			showText = add0(h)+":";
			var tmp2 = tmp%60;
			var m = (tmp-tmp2)/60;
			showText = showText+add0(m)+":"+add0(tmp2);
			$("#tlsLeftTime").text(showText);
		}else if(leftTime == -5){
			window.location.reload();
		}
		if(leftTime > -5){
			leftTime--;
		}
	}
	function add0(num){
		if(num<10)
			return "0"+num;
		return num;
	}